﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Model;
using DataAccess;
using Model.EntityModel;
using System.Collections.ObjectModel;

namespace Project
{
    /// <summary>
    /// Lógica de interacción para ViewAudienceContent.xaml
    /// </summary>
    public partial class ViewAudienceContent : UserControl
    {
        AudienceClass audience;
        public ViewAudienceContent()
        {
            InitializeComponent();
        }

        public ViewAudienceContent(AudienceClass aud)
        {
            InitializeComponent();
            audience = aud;
            UIWindowManager.SetWindowTitle(this, "Brigada De Protección a la Familia - ViewAudience");
            Complaint comp = new Complaint();
            comp = ComplaintDataAccess.GetComplaintById(aud.IdComplaint);
            Model.EntityModel.Actor Denouncer;
            Model.EntityModel.Actor Agressor;

            lbCase.Content = aud.IdComplaint;
            lbDate.Content = aud.Date;
            lbTime.Content = aud.Time;

            lblNatFact.Content = comp.IncidentNature;
            lblPlace.Content = comp.IncidentPlace;

            Denouncer = PersonAndActorDataAccess.GetActorByTypeAndComplaintId("Denunciante", comp.Id);
            lblNameDenouncer.Content = Denouncer.Person.Name;
            lblPaternDenouncer.Content = Denouncer.Person.PaternalName;
            if (!String.IsNullOrEmpty(Denouncer.Person.MaternalName))
                lblMaternDenouncer.Content = Denouncer.Person.MaternalName;

            Agressor = PersonAndActorDataAccess.GetActorByTypeAndComplaintId("Agresor", comp.Id);
            lblNameDenounced.Content = Agressor.Person.Name;
            lblPaternDenounced.Content = Agressor.Person.PaternalName;
            if (!String.IsNullOrEmpty(Agressor.Person.MaternalName))
                lblMaternDenounced.Content = Agressor.Person.MaternalName;
            tbReport.Text = aud.Report;
            Model.EntityModel.Person emp = PersonAndActorDataAccess.GetPersonByCi(aud.CiEmployee);
            //lbEmployee.Content = emp.Name + " " + emp.PaternalName + " " + emp.MaternalName;
        }

        private void Print_Click(object sender, RoutedEventArgs e)
        {
            var items = new ObservableCollection<UserControl>();
            items.Add(new PrintAudience(audience));
            var a = new PrintPreviewDialogV2(items);
            a.MenuItem_Click(null, null);
        }


        public void PrintPreview_Click(object sender, RoutedEventArgs e)
        {
            var items = new ObservableCollection<UserControl>();
            items.Add(new PrintAudience(audience));
            var a = new PrintPreviewDialogV2(items);
            a.ShowDialog();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            UIWindowManager.CleanWindow(this);
        }

        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            DrpDownPrintOptions.IsOpen = true;
        }
    }
}
